package com.codeblue.tools.codeGenerator;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

/**
 * Created by Administrator on 2016-02-29.
 */
public class d {
    public static void main(String[] args) {
        try {
            Class.forName("net.sourceforge.jtds.jdbc.Driver").newInstance();
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }

        String url = "jdbc:jtds:sqlserver://211.149.231.60:1433/Hd2016";
        String user = "sa";
        String psw = "1qazxsw2!@";
        Connection conn = null;
        try {
            conn = DriverManager.getConnection(url, user, psw);
            System.out.println("连接数据库成功");
            Statement sql  = conn.createStatement();
            ResultSet rs  = sql.executeQuery("select * from HD_User");
             while (rs.next())
            {
                System.out.println(rs.getString(2));
            }
            conn.close();
        } catch (Exception e) {
            System.out.println("连接数据库失败");
            e.printStackTrace();
        }

    }
}
